package com.example.hello.controller;

import com.example.hello.recommender.dto.BookRecommendationDTO;
import com.example.hello.service.RecommendationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/recommend")
public class RecommendationController {

    @Autowired
    private RecommendationService recommendationService;

    /**
     * 示例请求：GET /recommend?userId=1&topN=5
     * 返回 JSON 格式的推荐列表，每项包含图书详细信息和预测评分
     */
    @GetMapping
    public List<BookRecommendationDTO> getRecommendations(
            @RequestParam Integer userId,
            @RequestParam(defaultValue = "10") int topN) {

        return recommendationService.recommendBooks(userId, topN);
    }
}